<template>
  <MainLayout>
    <router-view></router-view>
    <el-card>
    <h3>数据字典管理</h3>
    <el-table :data="dictionaries" style="width: 100%">
      <el-table-column prop="key" label="键" width="150" />
      <el-table-column prop="value" label="值" />
      <el-table-column label="操作" width="120">
        <template #default="scope">
          <el-button size="small" @click="editDictionary(scope.row)">编辑</el-button>
          <el-button size="small" type="danger" @click="deleteDictionary(scope.row.key)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-button type="primary" @click="addDictionary">添加</el-button>
  </el-card>
  </MainLayout>
</template>

<script>
import MainLayout from '@/layouts/MainLayout.vue'
export default {
  components: {
    MainLayout
  },
  data() {
    return {
      dictionaries: [
        { key: 'status', value: '状态' },
        { key: 'type', value: '类型' }
      ]
    };
  },
  methods: {
    addDictionary() {
      this.dictionaries.push({ key: '', value: '' });
    },
    editDictionary(item) {
      console.log('编辑数据字典:', item);
    },
    deleteDictionary(key) {
      this.dictionaries = this.dictionaries.filter(item => item.key !== key);
    }
  }
};
</script>

<style scoped>
.el-card {
  margin-bottom: 20px;
}
</style>